/**
 * Created with IntelliJ IDEA.
 * User: mkadush
 * Date: 04.09.13
 * Time: 8:41
 * To change this template use File | Settings | File Templates.
 */



var treeLoader = new Ext.tree.TreeLoader({
    url: '../organization/jsonDynamic'
});

var tree = new Ext.tree.TreePanel({
    title: 'Organization',
    id: 'treepanel',
    loader: treeLoader,
    autoScroll: true,
    border: false,
    useArrows: true,
    root: {
        text: 'Организация',
        id: 'org_',
        iconCls: 'organizationIcon',
        expanded: true
    },

    tbar: [{
        xtype: 'toolbar',
        items: [{

            iconCls: 'expandTreeAll',
            text: 'Expand All',
            handler: function(){
                tree.expandAll();
            }
        },'-', {
            iconCls: 'collapseTreeAll',
            text: 'Collapse All',
            handler: function(){
                tree.collapseAll();
            }
        }]
    }],

    listeners: {
        contextmenu: onCtxMenu

    },

    sorters: [
        {
            property: 'text',
            direction: 'DESC'
        }
    ]

});

tree.addListener('click',onItemClick)

